

function updateName(code, name) {      
    var key = code.value;  
    name.selectedIndex = 0;
    for (var i = 1; i < name.length; i++) {          
        var kunta = name.options[i].value;           
        if (key.toUpperCase() == kunta.toUpperCase()) {
            name.selectedIndex = i;
            code.value = key.toUpperCase();
            name.onblur();
            break;
        }
    }       
}        
    
function updateCode(code, name) {  
    var s = name.selectedIndex;
    code.value = name.options[s].value;
    code.onblur();
} 
    
function setCookie( name, value, expires, path, domain, secure ) {  
    var today = new Date();  
    today.setTime( today.getTime() );  
    if ( expires ) {  
        expires = expires * 1000 * 60 * 60 * 24;  
    }  
    var expires_date = new Date( today.getTime() + (expires) );  
    document.cookie = name+"="+escape( value ) +  
    ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) +  
    ( ( path ) ? ";path=" + path : "" ) +  
    ( ( domain ) ? ";domain=" + domain : "" ) +  
    ( ( secure ) ? ";secure" : "" );  
}  
    
function getCookie( name ) {  
    var start = document.cookie.indexOf( name + "=" );  
    var len = start + name.length + 1;  
    if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {  
        return null;  
    }  
    if ( start == -1 ) return null;  
    var end = document.cookie.indexOf( ";", len );  
    if ( end == -1 ) end = document.cookie.length;  
    return unescape( document.cookie.substring( len, end ) );  
}  
    
function rememberFormInputs(elements) { 

    var els = elements;  
        
    for (var i = 0; i < els.length; i++) {  
        var el = els.item(i);  
        var prefix = 'input-';

        el.onblur = function() {
            var name = this.name;    
            var value = this.value;
            setCookie( prefix + name, value);
        };
            
        var old_value = getCookie(prefix + el.name);  
        if (old_value && old_value != '') {   
            el.value = old_value;
        }
        
    }  
}

function saveInfo(name, value, str)
{
    var xmlhttp;
    if (str.length==0)
    { 
        return;
    }
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            el.innerHTML=xmlhttp.responseText;
        }
    }
 
    xmlhttp.open("POST",str + '?' + name + '=' + escape(value),true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
    xmlhttp.send();
}